//
//  HotBoxView.m
//  ForestPack
//
//  Created by 郑洲 on 2018/7/9.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "HotBoxView.h"

@interface HotBoxView()

@property (nonatomic, strong) UIImageView *headImage;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *moneyLabel;

@end

@implementation HotBoxView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        UIView *headBg = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenX375(125), ScreenX375(147))];
        headBg.layer.borderColor = REXADECIMALCOLOR(@"#dcdcdc").CGColor;
        headBg.layer.borderWidth = 1;
        headBg.layer.cornerRadius = ScreenX375(2);
        headBg.clipsToBounds = YES;
        [self addSubview:headBg];
        
        self.headImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, ScreenX375(125), ScreenX375(83))];
        [headBg addSubview:self.headImage];
        
        self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(6), ScreenX375(95), ScreenX375(113), ScreenX375(16))];
        self.nameLabel.textColor = REXADECIMALCOLOR(@"#333333");
        self.nameLabel.font = Kfont(14);
        [headBg addSubview:self.nameLabel];
        
        self.moneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(6), ScreenX375(116), ScreenX375(113), ScreenX375(18))];
        self.moneyLabel.textColor = ThemeColor;
        self.moneyLabel.font = Kfont(14);
        [headBg addSubview:self.moneyLabel];
        
        UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, ScreenX375(144), ScreenX375(125), ScreenX375(3))];
        line.backgroundColor = ThemeColor;
        [headBg addSubview:line];
        
        UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, ScreenX375(125), ScreenX375(147))];
        [button addTarget:self action:@selector(select) forControlEvents:UIControlEventTouchUpInside];
        [headBg addSubview:button];
    }
    return self;
}

- (void)select {
    if (_selectClick) {
        _selectClick();
    }
}

- (void)initWithModel:(HotBoxModel *)model {
    [self.headImage sd_setImageWithURL:[NSURL URLWithString:model.index_pic] placeholderImage:nil options:SDWebImageRetryFailed];
    self.nameLabel.text = model.goods_name;
    self.moneyLabel.text = [NSString stringWithFormat:@"￥%@",model.price];
}

@end

@implementation HotBoxModel


@end
